package code;

public class IsValidBST_day16 {
    public static void main(String[] args) {
        Integer[] nums = new Integer[]{2,1,3} ;
        TreeNode root = new TreeNode();
        root=root.createTree(nums);
        System.out.println(isValidBST(root,-99999,99999));


    }
    public static boolean isValidBST(TreeNode root,long min,long max ) {
        if(root==null) return true;
        if(root.val>=max||root.val<=min) return false;
        return isValidBST(root.left,min,root.val)&&isValidBST(root.right,root.val,max);
    }
}
